/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.mapper.StoreRecordMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.mapper;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.processor.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class StoreRecordMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;

    public int GetNumInByOrderId(String poId, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from `dxq_storerecord` where `poid`= ? and ordertype = 1 and ytenant_id=?  AND  `dr`=0\n";
        parameter.addParam(poId);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int GetNumOutWaitByOrderId(String orderId, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from `dxq_storerecord` where `orderid`= ? and ordertype = 2 and ytenant_id=?  AND `dr`=0\n";
        parameter.addParam(orderId);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int GetNumInWaitByOrderId(String orderid, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from `dxq_storerecord` where `orderid`= ? and ordertype = 1 and ytenant_id=?  AND `dr`=0\n";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int GetNumOutByOrderId(String poId, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from `dxq_storerecord` where `poid`= ? and ordertype = 2 and ytenant_id=?  AND `dr`=0\n";
        parameter.addParam(poId);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

}
